#include<bits/stdc++.h>
using namespace std;
#define int long long
string change(string s)
{
	string s2 = "";
	int temp = 0;
	if (s[0] >= '0' && s[0] <= '9') {
		temp += s[0] - '0';
	} else {
		temp += s[0] - 'A' + 10;
	}
	temp *= 16;
	if (s[1] >= '0' && s[1] <= '9') {
		temp += s[1] - '0';
	} else {
		temp += s[1] - 'A' + 10;
	}
	temp = 255 - temp;

	if (temp / 16 >= 10) {
		s2 += 'A' + ((temp / 16) - 10);
	} else {
		s2 += temp / 16 + '0';
	}
	if (temp % 16 >= 10) {
		s2 += 'A' + ((temp % 16) - 10);
	} else {
		s2 += temp % 16 + '0';
	}
	return s2;
}
signed main()
{
	string s;
	cin >> s;
	if (s[0] != '#') {
		return 0;
	}
	string s1, s2, s3;
	s1 = s.substr(1, 2);
	s2 = s.substr(3, 2);
	s3 = s.substr(5, 2);
	cout << "#" << change(s1) << change(s2) << change(s3);
	return 0;
}
